import 'package:flutter/material.dart';

abstract class LogCtrlable {
  final List<LogClass> _logList = [];
  VoidCallback? logChangeListener;

  List<LogClass> get logList => _logList;

  void addLog(LogClass log) {
    logList.add(log);
    refreshLog();
  }

  void setLogChangeListener(
    VoidCallback onChange,
  ) {
    logChangeListener = onChange;
  }

  void cleanLog() {
    logList.clear();
    refreshLog();
  }

  void refreshLog() {
    logChangeListener?.call();
  }
}

class LogClass {
  final String log;
  late final int timestamp;
  final Color logColor;

  LogClass(this.log, this.logColor) {
    timestamp = DateTime.now().millisecondsSinceEpoch;
  }
}
